<template>
  <div>
    <h3>{{ username() }}</h3>
    <button @click="setname">修改username</button>
  </div>
</template>

<script>
export default {
  // 如果你直接传入的是一个值，则不是响应式,函数也是可以注入进来
  inject: ['username', 'setusername'],
  data() {
    return {}
  },
  methods: {
    setname() {
      console.log(this.username())
      // console.log(this.setusername)
      this.setusername()
    }
  }
}
</script>

<style lang="scss" scoped></style>
